package dongshi.daddy.flyweight;

import dongshi.daddy.flyweight.concreteflyweight.Color;
import dongshi.daddy.flyweight.factory.ChessFactory;
import dongshi.daddy.flyweight.flyweight.Chess;
import org.junit.Test;

public class FlyweightClient {

    @Test
    public void playChess() {
        //下黑子
        Chess backChess1 = ChessFactory.getChess(Color.BLACK);
        backChess1.draw(2, 5);

        //下白子
        Chess whiteChess = ChessFactory.getChess(Color.WHITE);
        whiteChess.draw(3, 5);

        //下黑子
        Chess backChess2 = ChessFactory.getChess(Color.BLACK);
        backChess2.draw(2, 6);

        System.out.println(String.format("backChess1:%d | backChess2:%d | whiteChess:%d",
                backChess1.hashCode(), backChess2.hashCode(), whiteChess.hashCode()));
    }
}
